package com.example.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description
 * @Author liumin0901@sunwayworld.com
 * @Date 2021/5/1 2:11
 */
@RestController
@RequestMapping("/fun")
public class FunctionController {

    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    @GetMapping("/template/{name}")
    public String template(@PathVariable("name") String name){
        redisTemplate.opsForValue().set("name", name);
        Object o = redisTemplate.opsForValue().get("name");
        assert o != null;
        return o.toString();
    }

}
